package com.xianggu.demo;

import com.xianggu.demo.observer.ConcreteObserver;
import com.xianggu.demo.observer.ConcreteSubject;
import com.xianggu.demo.observer.Observer;

import java.util.ArrayList;
import java.util.List;


public class ObserverPatternDemo {
    public static void main(String[] args) {
        ConcreteSubject subject = new ConcreteSubject();
        
        Observer observer1 = new ConcreteObserver("观察者1");
        Observer observer2 = new ConcreteObserver("观察者2");
        
        subject.registerObserver(observer1);
        subject.registerObserver(observer2);
        
        subject.setState("状态1");
        subject.setState("状态2");
        
        subject.removeObserver(observer1);
        subject.setState("状态3");
    }
}